package com.qianli.user.enums;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/3/3
 * Time: 上午10:44
 */
public enum ContactFriendTypeEnum {
    FRIEND(1, "朋友"),
    COLLEAGUE(2, "同事"),
    SCHOOLMATE(3, "同学");

    private Integer type;
    private String desc;

    ContactFriendTypeEnum(Integer type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public Integer getType() {
        return type;
    }

    public ContactFriendTypeEnum setType(Integer type) {
        this.type = type;
        return this;
    }

    public String getDesc() {
        return desc;
    }

    public ContactFriendTypeEnum setDesc(String desc) {
        this.desc = desc;
        return this;
    }
    
    public static List<String> getDescList() {
        List<String> list = new ArrayList<>();
        for (ContactFriendTypeEnum enumObj : ContactFriendTypeEnum.values()) {
            list.add(enumObj.getDesc());
        }
        return list;
    }

    public static ContactFriendTypeEnum getEnumByType(Integer type) {
        ContactFriendTypeEnum userContactFriendTypeEnum = null;
        for (ContactFriendTypeEnum enumObj : ContactFriendTypeEnum.values()) {
            if (enumObj.getType().equals(type)) {
                userContactFriendTypeEnum = enumObj;
                break;
            }
        }

        return userContactFriendTypeEnum;
    }
    
    public static ContactFriendTypeEnum getEnumByDesc(String desc) {
        ContactFriendTypeEnum userContactFriendTypeEnum = null;
        for (ContactFriendTypeEnum enumObj : ContactFriendTypeEnum.values()) {
            if (enumObj.getDesc().equals(desc)) {
                userContactFriendTypeEnum = enumObj;
                break;
            }
        }
        return userContactFriendTypeEnum;
    }
}
